﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace TCG.Engine
{
    public class Env
    {
        static Dictionary<Type, Func<object>> creators = new Dictionary<Type, Func<object>>();

        public static void Reg<T>(T obj)
        {
            creators[typeof(T)] = () => obj;
        }

        public static void Reg<T>(Func<T> func)
        {
            creators[typeof(T)] = () => func();
        }

        public static T Get<T>()
        {
            return (T)creators[typeof(T)]();
        }
    }
}
